* GSS data setup for: 
* Unions, Class Identification and Policy Attitudes
* Date: 03/31/22


*******************************************************************************
***** Data setup.
*******************************************************************************


* Demographics.
replace age = . if age == 98 | age == 99
gen age2 = age^2
replace educ = . if educ == 98 | educ == 99
recode educ (0/8 = 1) (9/11 = 2) (12 = 3) (13/15 = 4) (16/20 = 5), gen(edu5)
recode sex (2 = 1 "Yes") (1 = 0 "No"), gen(female)
recode race (1 = 1 "Yes") (2 3 = 0 "No"), gen(white)
recode race (2 = 1 "Yes") (1 3 = 0 "No"), gen(black)
recode race (3 = 1 "Yes") (1 2 = 0 "No"), gen(othrace)
replace realinc = . if realinc == 0
xtile inc5 = realinc, n(5)
recode partyid (0 = 1) (1 = 2) (2 = 3) (3 = 4) (4 = 5) (5 = 6) (6 = 7) (7 8 9 = .), gen(pid7) 
recode pid7 (1 2 3 = 1) (4 = 2) (5 6 7 = 3), gen(pid3a)
recode pid7 (1 2 = 1) (3 4 5 = 2) (6 7 = 3), gen(pid3b)
  label define pid7_lab 1 "Strong dem" 2 "Not str dem" 3 "Ind, near dem" 4 "Independent" 5 "Ind, near rep" 6 "Not str rep" 7 "Strong rep"
  label values pid7 pid7_lab
recode polviews (0 8 9 = .)

rename class_ subcls
replace subcls = . if inlist(subcls, 0, 5, 8, 9)
recode subcls (1 2 = 1 "Lower/working") (3 4 = 0 "Middle/upper"), gen(subcls_LW)
tab subcls, gen(subcls_)
recode union_ (1 = 1) (2 3 4 = 0) (0 8 9 = .), gen(union)
*recode union_ (1 2 3 = 1) (4 = 0) (0 8 9 = .), gen(union_hh)
*replace attend = . if attend == 9

*recode discpol (1 = 4 "Often") (2 = 3 "Sometimes") (3 = 2 "Rarely") (4 = 1 "Never") (0 8 9 = .), gen(discpol4)
*recode discpol4 (3 4 = 1 "Often/sometimes") (1 2 = 0 "Rarely/never"), gen(discpol2)

recode wrkstat (1 2 = 1 "Working") (3/9 = 0 "Not working/other"), gen(working)

* Region.
note region: New England = Maine, Vermont, New Hampshire, Massachusetts, Connecticut, Rhode Island
note region: Middle Atlantic = New York, New Jersey, Pennsylvania
note region: East North Central = Wisconsin, Illinois, Indiana, Michigan, Ohio
note region: West North Central = Minnesota, Iowa, Missouri, North Dakota, South Dakota, Nebraska, Kansas
note region: South Atlantic = Delaware, Maryland, West Virginia, Virginia, North Carolina, South Carolina, Georgia, Florida, District of Columbia
note region: East South Central = Kentucky, Tennessee, Alabama, Mississippi
note region: West South Central = Arkansas, Oklahoma, Louisiana, Texas
note region: Mountain = Montana, Idaho, Wyoming, Nevada, Utah, Colorado, Arizona, New Mexico
note region: Pacific = Washington, Oregon, California, Alaska, Hawaii

recode region (1 2 = 1 "Northeast") (3 4 = 2 "Midwest") (5 6 7 = 3 "South") (8 9 = 4 "West"), gen(region4)

recode region4 (3 = 1) (1 2 4 = 0), gen(south)

* Combine some EGP categories with small sample sizes.
recode egp10_11 (7 = 5) (11 = 10) (12 = .), gen(egp11_alt)
  label define egp11alt 1 "I" 2 "II" 3 "IIIa" 4 "IIIb" 5 "IVabc" 8 "V" 9 "VI" 10 "VIIab"
  label values egp11_alt egp11alt
* Variations of EGP with fewer categories.
recode egp10_10 (1 2 = 1) (3 = 2) (4 = 3) (7 = .) (8 9 10 11 = 4) (12 = .), gen(egp4)
recode egp10_10 (1 2 = 1) (3 = 2) (4 = 3) (7 = .) (8 = 4) (9 10 11 = 5) (12 = .), gen(egp5)

tab egp5, gen(egp5_)

* Reverse egp scale.
gen egp5rev = (egp5 * -1) + 6

* Gov reduce inequality.
recode eqwlth (0 8 9 99 = .) (1 = 7 "Govt reduce diff") (2 = 6) (3 = 5) (4 = 4) (5 = 3) (6 = 2) (7 = 1 "No govt action"), gen(govineq)
* Gov improve the standard of living of poor Americans.
recode helppoor (1 = 5 "Govt action") (2 = 4) (3 = 3 "Agree with both") (4 = 2) (5 = 1 "People help selves") (0 8 9 = .), gen(govhlppoor)
* Gov should help pay for medical care.
recode helpsick (1 = 5 "Govt should help") (2 = 4) (3 = 3 "Agree with both") (4 = 2) (5 = 1 "People help selves") (0 8 9 = .), gen(govhlpmed)
* Gov should do more/less to solve our country's problems.
recode helpnot (1 = 5 "Govt do more") (2 = 4) (3 = 3 "Agree with both") (4 = 2) (5 = 1 "Govt does too much") (0 8 9 = .), gen(govdomore)


* Add numeric values to labels.
numlabel , add

